import React, {Component} from "react";
import {inject, observer, observable} from "mobx-react";
import DetailInfo from "./DetailInfo"

@inject("activityStore")
@observer
class ActivityDetail extends Component {
    componentDidMount() {
        const activityId = this.props.match.params.id;
        this.props.activityStore.fetchActivityById(activityId);
    }

    verifyActivity = (v) => {
        const id = this.props.match.params.id;
        this.props.activityStore.verifyActivity(id, v);
    };

    render() {
        const {match, activityStore} = this.props;
        const activityId = match.params.id;
        const activity = activityStore.getActivity(activityId);
        if (!activity) {
            return null;
        }
        return (
            <div>
                <DetailInfo activity={activity}/>
            </div>
        );
    }
}

export default ActivityDetail;
